package ch07_GUI编程;

import javax.swing.*;

public class JScrollPaneDemo {
	public static void main(String[] args) {
		BaseFrame f =new BaseFrame("JScrollpane Demo");

		JPanel p = new JPanel();
		JScrollPane sp =new JScrollPane(p);

		sp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
		int count =5;
		JButton[] btns =new JButton[count];
		for(int i=0;i<btns.length;i++) {
			btns[i]=new JButton("按钮"+(i+1));
			p.add(btns[i]);
		}
		sp.setLocation(5, 5);
		sp.setSize(260,140);
		f.setSize(260,200);
		f.add(sp);
		f.showMe();
	}
}
